home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / prof / sun4c.md / profStack.s < prev    next >
Text File  |  1989-07-06  |  3KB  |  116 lines

  1. /* 
  2.  * profStack.s --
  3.  *
  4.  *    Procedures for managing stack traces.
  5.  *
  6.  * Prof_ThisFP --
  7.  *    Return the frame pointer of our caller.
  8.  *
  9.  * Prof_CallerFP --
  10.  *    Return the frame pointer of our caller's caller.
  11.  *    (mod, return frame pointer of our caller)
  12.  *
  13.  * Prof_NextFP --
  14.  *    Given a frame pointer, return the frame pointer to
  15.  *    the previous stack frame.
  16.  *
  17.  * Prof_ThisPC --
  18.  *    Given a frame pointer, return the PC from which this
  19.  *    frame was called.
  20.  *
  21.  * Copyright (C) 1985 Regents of the University of California
  22.  * All rights reserved.
  23.  */
  24. .seg    "data"
  25. .asciz  "$Header: /sprite/src/kernel/prof/sun3.md/RCS/profStack.s,v 8.1 89/02/14 10:34:40 brent Exp $ SPRITE (Berkeley)"
  26. .align 8
  27. .seg    "text"
  28.  
  29. #include "machConst.h"
  30. #include "machAsmDefs.h"
  31.  
  32. #if    defined(sun4) || defined(sparc)
  33. !    .globl    _Prof_Whence
  34. !    .globl    _Prof_NextFP
  35. !    .globl    _Prof_ThisFP
  36. !    .globl    _Prof_CallerFP
  37. !    .globl    _Prof_ThisPC
  38.     .globl    _Prof_CallerPC
  39.     .globl    _Prof_CalleePC
  40.  
  41. /*
  42.  * Prof_Whence, the stack looks like this when it gets called.
  43.  *    There is no link instruction so we are still using mcount's
  44.  *    (or whomever's) frame pointer.
  45.  *
  46.  *    a6 is the frame pointer register.
  47.  *
  48.  *     Bottom of the stack (it grows away from here)
  49.  *  |----------------------------|
  50.  *  | Args to Foo                |
  51.  *  |----------------------------|
  52.  *  | PC of jsr Foo              |
  53.  *  |----------------------------|
  54.  *  | Saved FP0                  |    <--  FP1     (Foo's frame)
  55.  *  |----------------------------|
  56.  *  | Saved registers            |
  57.  *  |----------------------------|
  58.  *  | PC of jsr mcount           |
  59.  *  |----------------------------|
  60.  *  | Saved FP1                  |    <--  FP2    (mcount's frame)
  61.  *  |----------------------------|
  62.  *  | Saved registers            |
  63.  *  |----------------------------|
  64.  *  | PC of jsr Prof_Whence      |
  65.  *  |----------------------------|    <--  SP
  66.  *  
  67.  */
  68. #ifdef NOTDEF
  69. _Prof_ThisFP:
  70.     movl    a6,d0        /* just the frame pointer */
  71.     rts
  72.  
  73. _Prof_CallerFP:
  74. /*    movl    a6@,a0
  75.     movl    a0@,d0 */
  76.     movl    a6@,d0        /* just our caller's frame pointer */
  77.     rts
  78.  
  79. _Prof_NextFP:
  80.     movl    sp@(4),a0
  81.     movl    a0@,d0
  82.     rts
  83.  
  84. _Prof_ThisPC:
  85.     movl    sp@(4),a0
  86.     movl    a0@(4),d0
  87.     rts
  88. #endif NOTDEF
  89.     /*
  90.      * Move the return pc for the routine that called mcount (that's our
  91.      * current frame) into the return value register and return.
  92.      */
  93. _Prof_CalleePC:
  94.     mov    %RETURN_ADDR_REG_CHILD, %o0
  95.     retl
  96.     nop
  97.  
  98.     /*
  99.      * Move the return pc for the routine that called the routine that called
  100.      * mcount (one frame before our current frame) into the return value
  101.      * register and return.  To do this, we must back up a window and push
  102.      * the value over to our real window and move back to our real window.
  103.      *
  104.      * INTERRUPTS MUST BE OFF!!!  (Or we'll be in trouble jumping about
  105.      * windows like this.)
  106.      */
  107. _Prof_CallerPC:
  108.     restore
  109.     mov    %RETURN_ADDR_REG_CHILD, %o4
  110.     save
  111.     mov    %i4, %o0
  112.     retl
  113.     nop
  114.  
  115. #endif    defined(sun4) || defined(sparc)
  116.